package com.panshi.controller;

import com.panshi.service.QuestionService;
import com.panshi.util.CommonResult;
import com.panshi.vo.PageSizeVO;
import com.panshi.vo.QuestionVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@Slf4j
@CrossOrigin
public class QuestionController {

    @Autowired
    private QuestionService questionService;

    @PostMapping("/queQu")
    public List<List<QuestionVO>> findQueQuery(@RequestBody PageSizeVO pageSizeVO){
        log.info("查询问题");
        List<QuestionVO> queQuery = questionService.findQueQuery(pageSizeVO);
        List<QuestionVO> querQuery = questionService.findQuerQuery(pageSizeVO);
        List<List<QuestionVO>> list = new ArrayList<>();
        list.add(queQuery);
        list.add(querQuery);
        return list;
    }

    @GetMapping("/queDe/{qid}")
    public CommonResult<String> delectQue(@PathVariable int qid){
        log.info("删除问题");
        questionService.deleteQue(qid);
        return new CommonResult<String>();
    }


    @GetMapping("/queDeNo/{qidno}")
    public CommonResult<String> updatequeNo(@PathVariable int qidno){
        log.info("删除问题");
        questionService.updatequeNo(qidno);
        return new CommonResult<String>();
    }


}
